package com.kmgames.ballsengine.rendering;

import com.badlogic.gdx.Gdx;
import com.badlogic.gdx.graphics.Camera;
import com.badlogic.gdx.graphics.GL10;

public class ClassicRenderer extends Renderer {
	float[] lightColor = { 1, 1, 1, 0 };
	float[] lightPosition = { 2, 5, 10, 0 };

	@Override
	public void prerender() {
		super.prerender();

		Gdx.gl.glClear(GL10.GL_COLOR_BUFFER_BIT | GL10.GL_DEPTH_BUFFER_BIT);
		Gdx.gl.glEnable(GL10.GL_DEPTH_TEST);
		Gdx.gl.glEnable(GL10.GL_LIGHTING);
		Gdx.gl.glEnable(GL10.GL_COLOR_MATERIAL);
		Gdx.gl.glEnable(GL10.GL_LIGHT0);

		Gdx.gl10.glLightfv(GL10.GL_LIGHT0, GL10.GL_DIFFUSE, lightColor, 0);
		Gdx.gl10.glLightfv(GL10.GL_LIGHT0, GL10.GL_POSITION, lightPosition, 0);

		Gdx.gl10.glLoadIdentity();
	}

	public void render(Renderable renderable) {
		renderable.render();
	}

	public void setCamera(Camera camera) {
		camera.apply(Gdx.gl10);
	}
}
